package vip.zhenzicheng.config;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhenzicheng
 * @DESCRIPTION: curator config配置类
 * @DATE: 2022/04/24 5:11 PM
 */
@Configuration
public class CuratorConfig {
  @Value("config.defaultServerIp")
  private String defaultServerIp;


  @Bean
  public CuratorFramework curatorFramework() {
    // 重试策略
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    return CuratorFrameworkFactory.newClient(defaultServerIp, retryPolicy);
  }
}
